package com.itc.dispatch.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.itc.common.core.domain.R;
import com.itc.dispatch.domain.FlightDevice;
import com.itc.dispatch.domain.FlightOperationMonitoring;
import com.itc.dispatch.domain.FlightTimeExchange;
import com.itc.dispatch.domain.dto.DisFlightSearchValueDto;
import com.itc.dispatch.domain.dto.DisFlightSearchValuePageDto;
import com.itc.dispatch.domain.dto.FlightDevicePageDto;
import com.itc.dispatch.domain.vo.FieldVo;
import com.itc.dispatch.domain.vo.FlightLinkInfoVo;
import com.itc.dispatch.service.FlightOperationMonitoringService;
import com.itc.system.api.listener.CastAdsb;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


@RestController
@CrossOrigin
@RequestMapping("/flight/monitoring")
@Api(value = "flightOperationMonitoringService", tags = "航班运行监控配置管理模块")
public class FlightOperationMonitoringController {

    @Autowired
    private FlightOperationMonitoringService service;

    /**
     * 保障信息界面修改/保存
     */
    @ApiOperation(value = "保障信息界面修改/保存")
    @PostMapping("/save/assurance")
    public R saveAssurance(@RequestBody FlightOperationMonitoring dto){
        return service.saveAssurance(dto);
    }

    /**
     * 列表配置下拉字段信息获取
     * @return
     */
    @ApiOperation(value = "列表配置下拉字段信息获取")
    @GetMapping("/config/getfiled")
    public R<List<FieldVo>> getFiled(){
        return service.getFiled();
    }

    /**
     * 根据筛选条件获取展示数据
     * @return
     */
    @ApiOperation(value = "根据筛选条件获取展示数据")
    @PostMapping("/getlist/search")
    public R<Page<FlightOperationMonitoring>> getSearch(@RequestBody DisFlightSearchValuePageDto pageDto){
        Page page = new Page();
        page.setSize(pageDto.getSize());
        page.setCurrent(pageDto.getCurrent());
        page.setSearchCount(true);
        return service.getSearch(page,pageDto);
    }

    /**
     * 根据筛选条件获取展示数据（全部）
     * @return
     */
    @ApiOperation(value = "根据筛选条件获取展示数据（全部）")
    @PostMapping("/list")
    public R<List<FlightOperationMonitoring>> getList(@RequestBody DisFlightSearchValuePageDto pageDto){
        return service.getList(pageDto);
    }

    /**
     * 根据数据列表查询下拉选数据信息
     * @return
     */
    @ApiOperation(value = "根据数据列表查询下拉选数据信息")
    @PostMapping("/list/down/selection")
    public R<List<Object>> getDownSelectionList(@RequestBody DisFlightSearchValuePageDto pageDto){
        return service.getDownSelectionList(pageDto);
    }


    /**
     * 运行监控页面，下拉框筛选条件获取数据
     * @return
     */
    @ApiOperation(value = "运行监控页面，下拉框筛选条件获取数据")
    @PostMapping("/getlist/down")
    public R<List<Object>> getDown(@RequestBody FieldVo dto){
        return service.getDown(dto);
    }


    /**
     * 运行监控页面数据详情
     * @return
     */
    @ApiOperation(value = "运行监控页面数据详情")
    @GetMapping("/detail/{id}")
    public R<FlightOperationMonitoring> detail(@PathVariable("id") String id){
        return service.detail(id);
    }

    /**
     * 根据航班摄像头视频播放信息
     * @return
     */
    @ApiOperation(value = "根据航班摄像头视频播放信息")
    @PostMapping("/video/page")
    public R<Page<FlightDevice>> getFlightVideoPage(@RequestBody FlightDevicePageDto pageDto){
        Page page = new Page();
        page.setSize(pageDto.getSize());
        page.setCurrent(pageDto.getCurrent());
        page.setSearchCount(true);
        return service.getFlightVideoPage(page,pageDto);
    }

    /**
     * 根据航班摄信息获取ADSB信息
     * @return
     */
    @ApiOperation(value = "根据航班摄信息获取ADSB信息")
    @GetMapping("/gis/list/{flightId}")
    public R<List<CastAdsb>> getFlightGisList(@PathVariable(value = "flightId") String flightId){
        return service.getFlightGisList(flightId);
    }

    /**
     * 根据航班摄信息获取前后序航班信息
     * @return
     */
    @ApiOperation(value = "根据航班摄信息获取前后序航班信息")
    @GetMapping("/link/list/{flightId}")
    public R<List<FlightLinkInfoVo>> getFlightLinkList(@PathVariable(value = "flightId") String flightId){
        return service.getFlightLinkList(flightId);
    }

    /**
     * 根据航班摄信息获取时隙交换航班信息
     * @return
     */
    @ApiOperation(value = "根据航班摄信息获取时隙交换航班信息")
    @GetMapping("/time/exchange/{flightId}")
    public R<List<FlightTimeExchange>> getTimeExchange(@PathVariable(value = "flightId") String flightId){
        return service.getTimeExchange(flightId);
    }

}
